package cn.school.mybatis.servlet;


import cn.school.mybatis.pojo.Grade;
import cn.school.mybatis.service.GradeService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/doGradeInfoServlet")
public class doGradeInfoServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        resp.setContentType("text/html;charset=UTF-8");
//        PrintWriter out = resp.getWriter();
        List<Grade> list = GradeService.GRADE_SERVICE.searchAll();
        req.setAttribute("grades",list);
        req.getRequestDispatcher("/WEB-INF/AdminLTEdemo01/s_grade/s_gradeInfo.jsp").forward(req,resp);


    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }
}
